package com.example.thread;

public class Main1 {

    public static void main(String[] args) throws InterruptedException {
        Thread thread = new Thread(() -> {
            int i =10;
            while (true) {
                    System.out.println(Thread.currentThread().getState());
                boolean interrupted = Thread.currentThread().isInterrupted();
                if (interrupted) {
                    System.out.println("interrupted:" + interrupted);
                    break;
                }
            }
        });
        thread.start();
        System.out.println("1"+thread.getState());
        Thread.sleep(1000);
        new Thread(()->{
            thread.interrupt();
        }).start();
        System.out.println("2"+thread.getState());
        System.out.println("3"+"-"+thread.isInterrupted());
        Thread.sleep(1000);

        System.out.println("--------");
        System.out.println(thread.getState());
        Thread.sleep(1000);

    }

}
